define(function(require, exports, module) {
    var ALL = require("../../common/all"),
        CONFIG = ALL.CONFIG,
        METHOD = ALL.METHOD,
        Dialog = ALL.Dialog,
        Init = ALL.Init;

    var _Dialog = new Dialog({
        title : "提示",
        content : "<p>是否删除？</p>",
        text4Btn: ["确定", "取消"],
        class4Btn: ["", "line"]
    });

    var _vm = Init.initVue({
        data : {
            col_id : "",
            user_name : "",
            list : [],
            cur : 1,
            all : 0,
            search : false
        },
        methods: {
            reSearch : function() {
                this.search = true;
                this.getData(1);
            },
            reset : function() {
                this.search = false;
                _vm.col_id = "";
                _vm.user_name = "";
            },
            getData : function(n) {
                var obj = {
                    page: n, num: 10,
                    col_id : _vm.col_id,
                    user_name : _vm.user_name
                };
                METHOD.loading.show();
                METHOD.ajax("purchaseblist/list",obj).done(function(json){
                    METHOD.loading.hide();
                    _vm.list = json.data;
                    _vm.all = json.page.pages;
                }).fail(function(){
                    METHOD.loading.hide();
                });
            },
            remove : function(id) {
                _Dialog.showUI(function(i) {
                    if (i == 0) {
                        METHOD.loading.show();
                        METHOD.ajax("purchaseblist/delete",{pb_id:id},{type:'post'}).done(function(json){
                            METHOD.loading.hide();
                            METHOD.alert("删除成功");
                            _vm.getData(1);
                        }).fail(function(){
                            METHOD.loading.hide();
                        });
                    }
                    this.hideUI();
                });
            },
            export : function(id) {
                METHOD.loading.show();
                METHOD.ajax("purchaseblist/export_detail", {pb_id:item.id}, {type:"post"}).done(function(json){
                    METHOD.loading.hide();
                    METHOD.alert("导出成功");
                    _vm.getData(1);
                }).fail(function(){
                    METHOD.loading.hide();
                });
            }
        }
    });

    _vm.getData(1);
});

